const Koa = require('koa');
const parser = require('koa-bodyparser');

const InitManager = require('./core/init')
const catchError = require('./middlewares/exception')

const app = new Koa()
const port = 4002

app.use(catchError)
app.use(parser())
InitManager.initCore(app)
InitManager.loadConfig()
InitManager.loadHttpException()

/** require-directory成功替代以下的方式 */
// const book = require('./api/v1/book')
// const classic = require('./api/v1/classic')
// app.use(book.routes())
// app.use(classic.routes())

app.listen(port, () => { console.log(`listen port ${port}`)})


